/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.thompv.BaitapMuc1_2;
import java.util.Scanner;
/**
 *
 * @author SONY
 */
public class Bai3Muc2 {
    static int []a=new int[100];
    static int ok = 0,n;
    public static void Init()
    {
        for(int i=1;i<=n;i++)
            a[i]=0;
    }
    public static void sinh()
    {
        int j=n;
        while(j>0&&a[j]==1)
        {
            a[j]=0; j--;
        }
        if(j==0) ok=1;
        else a[j]=1;
    }
    public static void in()
    {
        for(int i=1;i<=n;i++)
            System.out.print(a[i]);
        System.out.println("");
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int stop=1;
        String s;
        System.out.println("Nhap do dai xau: ");
        while(stop==1)
        {
            try
            {
                s=sc.nextLine();
                if(s.length()<1) throw new Exception("");
                n=Integer.parseInt(s);
                if(n<=0) throw new Exception("");
                stop=0;
                Init();
                System.out.println("Ket qua:");
                while(ok==0)
                {
                    in();
                    sinh();
                }
            }
            catch (Exception e)
            {
                System.out.println("Nhap lai");
            }
        }
    }
}
